/*
// ICS 314 Calendar Project
//
// Author: Ryne Okimoto
//
// Filename: CalendarGUI.java
//
// Description: Class for the Calendar GUI
//
*/

import javax.swing.*;
import java.awt.*;

public class CalendarGUI
{
	JLabel         nameLabel, locationLabel, resourceLabel, priorityLabel, privacyLabel;
	JLabel         descriptionLabel;
	JTextField     nameField, locationField, resourceField;
	JList          priorityList, privacyList;
	JTextArea      descriptionArea;
	JButton        submitButton;
	
	String priorityChoices[] = {"None", "Low", "Medium", "High"};
	String privacyChoices[] = {"Public", "Private", "Confidential"};

	public CalendarGUI()
	{
		Dimension d;
		
		/* Window components */
		nameLabel            = new JLabel("Event name");
		nameField            = new JTextField(30);
		locationLabel        = new JLabel("Location");
		locationField        = new JTextField(30);
		resourceLabel        = new JLabel("Resources");
		resourceField        = new JTextField(30);
		
		priorityLabel        = new JLabel("Priority");
		priorityList         = createList(priorityChoices);
		privacyLabel         = new JLabel("Privacy");
		privacyList          = createList(privacyChoices);
		descriptionLabel     = new JLabel("Description");
		descriptionArea      = new JTextArea(30, 30);
		
		d = descriptionLabel.getPreferredSize();
		
		nameLabel.setPreferredSize(new Dimension(d.width + 10, d.height));
		locationLabel.setPreferredSize(new Dimension(d.width + 10, d.height));
		resourceLabel.setPreferredSize(new Dimension(d.width + 10, d.height));
		priorityLabel.setPreferredSize(new Dimension(d.width + 50, d.height));
		privacyLabel.setPreferredSize(new Dimension(d.width + 50, d.height));
		descriptionLabel.setPreferredSize(new Dimension(d.width + 10, d.height));
		
		priorityLabel.setHorizontalAlignment(JLabel.LEFT);
		privacyLabel.setHorizontalAlignment(JLabel.LEFT);

		submitButton         = new JButton("Create Event");
	}
	
	public static void main(String[] args)
	{
		//submitButton.addActionListener(new buttonClick(submitButton));

		/* Add components to panel */
// 		nameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
// 		windowContent.add(nameLabel);
// 		windowContent.add(nameField);
// 		windowContent.add(locationLabel);
// 		windowContent.add(locationField);
// 		windowContent.add(resourceLabel);
// 		windowContent.add(resourceField);
// 		
// 		windowContent.add(priorityLabel);
// 		windowContent.add(priorityList);
// 		windowContent.add(privacyLabel);
// 		windowContent.add(privacyList);
// 		windowContent.add(descriptionLabel);
// 		windowContent.add(descriptionArea);
// 		windowContent.add(submitButton);
		
		CalendarGUI cal = new CalendarGUI();
		cal.createWindow();
	}
	
	private void createWindow()
	{
		JFrame mainWindow = new JFrame("Eventer");
		mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		mainWindow.setContentPane(createLayout());
		
		mainWindow.pack();
		mainWindow.setVisible(true);
	}
	
	private JList createList(String[] list)
	{
		JList menu = new JList(list);
		menu.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		return menu;
	}
	
	private JPanel createLayout()
	{
		JPanel windowContent = new JPanel();
		windowContent.setLayout(new BoxLayout(windowContent, BoxLayout.Y_AXIS));
		
		Box temp = Box.createHorizontalBox();
		temp.add(nameLabel);
		temp.add(nameField);
		windowContent.add(temp);
		
		temp = Box.createHorizontalBox();
		temp.add(locationLabel);
		temp.add(locationField);
		windowContent.add(temp);
		
		temp = Box.createHorizontalBox();
		temp.add(resourceLabel);
		temp.add(resourceField);
		windowContent.add(temp);
		
		temp = Box.createHorizontalBox();
		temp.add(priorityLabel);
		temp.add(priorityList);
		windowContent.add(temp);
		
		temp = Box.createHorizontalBox();
		temp.add(privacyLabel);
		temp.add(privacyList);
		windowContent.add(temp);
		
		temp = Box.createHorizontalBox();
		temp.add(descriptionLabel);
		temp.add(descriptionArea);
		windowContent.add(temp);
		
		windowContent.add(submitButton);
		
		return windowContent;
	}
	
}